package com.link.base.base.product.controller;


import com.link.base.base.product.model.ProductAttr;
import com.link.base.base.product.service.ProductAttrService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.cllog.LCLogger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author unknown
 * @date unknown
 * @comments 产品系列或者产品品牌查询，用于弹出框显示
 */
@Controller
@RequestMapping("/link/productAttr")
public class ProductAttrController extends BasicController<ProductAttr> {

    @Resource
    private ProductAttrService productAttrService;

    @Override
    public BasicService<ProductAttr> getBasicService() throws Exception {
        return productAttrService;
    }

    @RequestMapping(value = "/queryByType")
    @ResponseBody
    public Map<String, Object> queryByType(ProductAttr productAttr, HttpSession session, HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<String, Object>();
        try {
            List<ProductAttr> productAttrList = productAttrService.queryByType(productAttr);
            result.put("success", true);
            result.put("result", productAttrList);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}
